home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14871 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: admaix.sunydutchess.edu!ub!newserve!rebecca!rpi!not-for-mail
  2. From: floydb1@lib104.its.rpi.edu (Barry B Floyd)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: strstream destruction
  5. Date: 1 Apr 1996 11:01:01 -0500
  6. Organization: Rensselaer Polytechnic Institute, Troy, NY.
  7. Message-ID: <4joujt$72p@lib104.its.rpi.edu>
  8. References: <315AD92C.726D@itd.ssb.com> <4jhgt0$17f@piper.logicon.com>
  9. NNTP-Posting-Host: lib104.its.rpi.edu
  10. X-newsreader: xrn 7.04-beta-11
  11.  
  12.  
  13. This works for me:
  14.  
  15. String StrStrFunc ( void )     // some function using strstream
  16. {
  17.     ostrstream a_stream ;    // 
  18.     String     a_string ;    // a 'string' class (char *)
  19.  
  20.     a_stream << a_variable    // any type
  21.          << ends ;    // null terminate string
  22.  
  23.     a_string = a_stream.str() ; // get the buffer
  24.  
  25.     a_stream.freeze(0) ;    // unfreeze buffer
  26.  
  27.     return ( a_string ) ;     // out of scope, deletes string
  28.                 // returns copy
  29. }
  30. -- 
  31. +--------------------------------------------------------------------+ 
  32. | Barry B. Floyd                   \\\               floydb1@rpi.edu |
  33. | RPI Alum. '84 '87 '88              \\\                             |
  34. +--------------------------------------------------------------------+
  35.